<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?>
<?php $this->load->view('common/head'); ?>

<?php $this->load->view('common/header'); ?>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <?php $this->load->view('common/sidebar'); ?>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <?php $this->load->view('common/breadcrumbs'); ?>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">

                <?php $this->load->view('common/set'); ?>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form class="form-horizontal" action="<?php echo site_url(X_URL . 'drivers/update'); ?>"
                              method="post">
                            <?php echo csrf_hidden(); ?>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 用户名 </label>
                                <div class="col-sm-9">
                                    <input type="text"
                                        <?php if (isset($member) && $member['user_id'] == 1) { ?>
                                            readonly
                                        <?php } else { ?>
                                            name="user"
                                        <?php } ?>
                                           class="rcol-xs-10 col-sm-5" value="<?php if (isset($member)) {
                                        echo $member["user_name"];
                                    } ?>">
                                    <input type="hidden" name="user_id" value="<?php if (isset($member)) {
                                        echo $member["user_id"];
                                    } ?>">
                                    <span class="help-inline col-xs-12 col-sm-7">
											<?php if (isset($member) && $member['user_id'] == 1) { ?><span
                                                    class="middle">无法修改</span><?php } ?>
											</span>
                                </div>
                            </div>

                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-10"> 用户组 </label>
                                <div class="col-sm-9">
                                    <?php if (isset($member) && $member['user_id'] == 1) { ?>
                                        <?php foreach ($usergroup as $key => $val) { ?>

                                            <?php if ($val['id'] == $member['user_group']) { ?>
                                                <input type="text" class="col-xs-10 col-sm-5"
                                                       value="<?php echo $val['title']; ?>"
                                                       readonly>
                                                <input type="hidden" name="user_group" id="user_group"
                                                       class="col-xs-10 col-sm-5" value="<?php echo $val['id']; ?>">
                                            <?php } ?>

                                        <?php } ?>
                                    <?php } else { ?>
                                        <select id="user_group" name="user_group" class="rcol-xs-10 col-sm-5">
                                            <?php foreach ($usergroup as $key => $val) { ?>
                                                <option value="<?php echo $val['id']; ?>"
                                                    <?php if (isset($member) && $val['id'] == $member['user_group']) { ?>
                                                        selected="selected"
                                                    <?php } ?>
                                                ><?php echo $val['title']; ?></option>
                                            <?php } ?>
                                        </select>
                                    <?php } ?>
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle">请慎重选择用户组</span>
											</span>
                                </div>
                            </div>

                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 用户密码 </label>
                                <div class="col-sm-9">
                                    <input type="password" name="user_password" id="user_password" placeholder="用户密码"
                                           class="col-xs-10 col-sm-5" value="">
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle">留空不修改</span>
											</span>
                                </div>
                            </div>

                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-4"> 性别 </label>
                                <div class="col-sm-9">
                                    <select id="user_sex" name="user_sex" class="multiselect">
                                        <option value="0"
                                                <?php if (isset($member) && $member['user_sex'] == 0){ ?>selected="selected"<?php } ?>
                                        >保密
                                        </option>
                                        <option value="1"
                                                <?php if (isset($member) && $member['user_sex'] == 1){ ?>selected="selected"<?php } ?>
                                        >男
                                        </option>
                                        <option value="2"
                                                <?php if (isset($member) && $member['user_sex'] == 2){ ?>selected="selected"<?php } ?>
                                        >女
                                        </option>
                                    </select>
                                </div>
                            </div>

                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-6"> 电话号码 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="user_tel" id="user_tel" placeholder="电话号码"
                                           class="col-xs-10 col-sm-5" value="<?php if (!empty($member['user_tel'])) {
                                        echo $member['user_tel'];
                                    } ?>">
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle"></span>
											</span>
                                </div>
                            </div>


                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-6"> 紧急联系 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="user_urgent_tel" id="user_urgent_tel" placeholder="紧急联系号码"
                                           class="col-xs-10 col-sm-5"
                                           value="<?php if (!empty($member['user_urgent_tel'])) {
                                               echo $member['user_urgent_tel'];
                                           } ?>">
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle"></span>
											</span>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-7">服务城市</label>
                                <div class="col-sm-9">
                                    <select name="destination_country" id="destination_country" class="select2"
                                            size="1">
                                        <option value="0">请选择国家</option>
                                        <?php if (isset($area) && !empty($area)) { ?>
                                            <?php foreach ($area as $key => $val) { ?>
                                                <option value="<?php echo $val['area_id']; ?>"
                                                        <?php if (isset($member) && $member['user_district'] == $val['area_id']){ ?>selected="selected"<?php } ?> ><?php echo $val['area_name']; ?></option>
                                            <?php } ?>
                                        <?php } ?>
                                    </select>
                                    <select name="destination_city" id="destination_city" class="select2" size="1">
                                        <option value="0">请选择城市</option>
                                        <?php if (isset($city) && !empty($city)) { ?>
                                            <?php foreach ($city as $key => $val) { ?>
                                                <option value="<?php echo $val['area_id']; ?>"
                                                        <?php if (isset($member) && $member['user_dress'] == $val['area_id']){ ?>selected="selected"<?php } ?> ><?php echo $val['area_name']; ?></option>
                                            <?php } ?>
                                        <?php } ?>
                                    </select>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right"
                                       for="form-field-7">会员积分</label>
                                <div class="col-sm-9">
                                    <input type="text" name="user_credit" id="user_credit" placeholder="会员积分"
                                           class="col-xs-10 col-sm-5"
                                           value="<?php if (!empty($member['user_credit'])) {
                                               echo $member['user_credit'];
                                           } ?>">
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle"></span>
											</span>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <?php if (!empty($car_info)) { ?>
                                <div class="form-group">
                                    <label class="col-sm-1 control-label no-padding-right" for="form-field-1">
                                        车辆等级 </label>
                                    <div class="col-sm-9">
                                        <select id="car_seat" name="car_seat"
                                                class="multiselect col-xs-10 col-sm-5 select2">
                                            <option value="">可选择</option>
                                            <?php if (isset($car_seat_format)) { ?>
                                                <?php foreach ($car_seat_format as $key => $val) { ?>
                                                    <option value="<?php echo $val['id']; ?>"
                                                            <?php if (isset($car_info) && $car_info['car_seat'] == $val['id']){ ?>selected="selected"<?php } ?> ><?php echo $val['car_seat']; ?></option>
                                                <?php } ?>
                                            <?php } ?>
                                        </select>
                                    </div>
                                </div>
                            <?php } ?>
                            <br>
                            <div class="col-md-offset-2 col-md-9">
                                <button class="btn btn-info" type="submit">
                                    <i class="icon-ok bigger-110"></i>
                                    提交
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="reset">
                                    <i class="icon-undo bigger-110"></i>
                                    重置
                                </button>
                            </div>
                        </form>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
</div><?php $this->load->view('common/footer'); ?>


<?php $this->load->view('common/footerjs'); ?>
<!-- inline scripts related to this page -->
<script>
    var service_url = "<?php echo site_url('manage/CarService/get_service');?>";
    var area_url = "<?php echo site_url('manage/Area/get_area');?>";
    $(function () {
        $(".select2").select2();
        var departure_city_select2 = $("#departure_city").select2();
        var destination_city_select2 = $("#destination_city").select2();
        $("#departure_country").on("select2:select", function (e) {
            console.log($(this).val());
            var p_id = $(this).val();
            if (p_id > 0) {
                $.ajax({
                    method: "GET",
                    url: area_url,
                    data: {p_id: p_id}
                }).done(function (data) {
                    // console.log(data);
                    $("#departure_city").html(data);
                    departure_city_select2.val(0).trigger("change");
                })
            } else {
                $("#departure_city").html('<option selected="selected" value="0">可选择</option>');
                departure_city_select2.val(0).trigger("change");
            }
        });
        $("#destination_country").on("select2:select", function (e) {
            console.log($(this).val());
            var p_id = $(this).val();
            if (p_id > 0) {
                $.ajax({
                    method: "GET",
                    url: area_url,
                    data: {p_id: p_id}
                }).done(function (data) {
                    // console.log(data);
                    $("#destination_city").html(data);
                    destination_city_select2.val(0).trigger("change");
                })
            } else {
                $("#destination_city").html('<option selected="selected" value="0">可选择</option>');
                destination_city_select2.val(0).trigger("change");
            }
        });
    });
</script>
</body>
</html>
